import router from './router'
import { getToken } from './utils/auth'


const whiteList = ['/login'] // 不重定向白名单
router.beforeEach((to, from, next) => {
    if (getToken()) {

        // 设置浏览器头部标题
        if(to.path === '/login') {
            next({ path: '/' })
        } else {
            next()
        }
    } else {
        // 设置浏览器头部标题


        if (whiteList.indexOf(to.path) !== -1) {
            next()
        } else {
            next('/login')
        }
    }
})

router.afterEach(() => {
    //设置标题

  window.scrollTo(0,0);
})
